home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 14208 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: news.ov.com!news
  2. From: glenn@ov.com (Fletcher.Glenn@ov.com)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: HELP: system() exit status
  5. Date: 12 Apr 1996 15:42:36 GMT
  6. Organization: OpenVision
  7. Message-ID: <4kltlc$7mc@spanky.pls.ov.com>
  8. References: <4kk8m6$omb@news.accent.net>
  9. Reply-To: glenn@ov.com
  10. NNTP-Posting-Host: foghorn.pls.ov.com
  11.  
  12. In article omb@news.accent.net, dallaire@megatoon.com (Guy Dallaire) writes:
  13. >Hi,
  14. >
  15. >I have a program which does a lot of "system()" calls here.  Is it
  16. >safe to assume that ANY return code other than 0 (on a UNIX) system
  17. >means that the command specified as a parameter to system() did dot
  18. >work ?  
  19. >
  20. >NOTE: I also checked for -1 which indicates that system() could not
  21. >spawn the command.
  22. >
  23. >Also: Most man pages do not explicitly state what return status one
  24. >can expect after calling some system call/utility. For example, it's
  25. >not stated that the `cp` command exits with value x, y, or z depending
  26. >on the case where the source file is not present, the destination file
  27. >is write protect, anmd so on. Can was assume that any return status of
  28. >0 means that all went well and anything else means there has been an
  29. >error ?
  30. >
  31. >That question always puzzled me...
  32. >
  33. >                Thanks !
  34. >
  35. >P.S.: Please reply by e-mail also
  36. >
  37.  
  38.  
  39. It would have been better to post this to comp.unix.programmer.
  40.  
  41. A system() call returns a union __wait as defined in <sys/wait.h>.
  42. In a sparc system, this basically boils down to the lower two bytes
  43. of an int containing the following values:
  44. The higher byte contains the "exit" value from the indicated command.
  45. The lower byte contains the number of the signal that terminated
  46. the indicated command (if any).  A zero means no signal.
  47.  
  48.         Fletcher.Glenn@ov.com
  49.  
  50.  
  51.